<?php
	require_once($_SERVER["DOCUMENT_ROOT"]."/global.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/modules/security_mod.php");
        require_once($_SERVER["DOCUMENT_ROOT"]."/modules/settings_mod.php");
        
	SecurityMod::login();

	$permissions = $_SESSION["account"]->getPermissions();
	if ($permissions->is_banned())
		SecurityMod::logout();
	$level = $_SESSION["account"]->getLevel();
	
	if($level == "Open"){
		SecurityMod::logout();
	}

	$name = $_SESSION["account"]->getName();
	$universe = $_SESSION["account"]->getUniverse();
        
        $returnURL = $_POST["returnurl"];
        if(isset($returnURL)){
            if(trim($returnURL) != "")
                $mainURL = $returnURL;
        }
        else
            $mainURL = SettingsMod::PAGE_STARTING_PAGE;
?>
<html>
<head>
	<title>Federation Infocenter</title>
	<link rel="stylesheet" href="main.css">
	<link href="favicon.ico" type=image/x-icon rel="shortcut icon">
</head>
<body style="margin:0">
	<table width="100%" height="100%">
	<tr height="20">
		<td align="center"><?php
		echo('<img src="http://static.pardus.at/various/universes/'.strtolower($universe).'_16x16.png"');
		echo(' title="'.$universe.': '.$name.' ('.$level.')" style="vertical-align: middle;" alt="'.$universe.': '.$name.' ('.$level.')"');
		echo(' border="0" height="13" width="13"> '."\n");
		echo('			<span style="font-weight: bold;">'.$name.'</span> <span style="font-weight: bold; color: #FF0000">('.$level.')</span> | '."\n");
		if (SettingsMod::ENABLE_MAIN_PAGE)
			echo('			<a href="main.php" target="mainFrame">Main</a> | '."\n");
		if (SettingsMod::ENABLE_COMBAT_SHARE && $permissions->has(Permissions::VIEW_COMBATS)) {
			echo('			<a href="combats.php?universe=');
			echo($universe);
			echo('" target="mainFrame">Combats</a> | '."\n");
			}
		if (SettingsMod::ENABLE_HACK_SHARE && $permissions->has(Permissions::VIEW_HACKS)) {
			echo('			<a href="hacks.php?universe=');
			echo($universe);
			echo('" target="mainFrame">Hacks</a> | '."\n");
			}
		if (SettingsMod::ENABLE_MISSION_SHARE && $permissions->has(Permissions::VIEW_MISSIONS)) {
			echo('			<a href="missions.php?universe=');
			echo($universe);
			echo('" target="mainFrame">Missions</a> | '."\n");
			}
		if ($level == "Admin" || $_SESSION["account"]->getBasic() == 1) {
			echo('			<a href="alerts.php" target="mainFrame">Alerts</a> | '."\n");
		}
                if ($_SESSION["account"]->getAdvanced() == 1 || $level == "Admin"){
                        echo('			<a href="manual_alert.php" target="mainFrame">Manual alert</a> | '."\n");
                }
                if ($_SESSION["account"]->getAdvanced() == 1 || $level == "Admin"){
                        echo('			<a href="safe_tile.php" target="mainFrame">Safe tiles</a> | '."\n");
                }
                if ($_SESSION["account"]->getChatLevel() == 3 || $level == "Admin"){
                        echo('			<a href="chat_channels.php" target="mainFrame">Channels</a> | '."\n");
                }
		if ($level == "Admin") {
			echo('			<a href="accounts.php" target="mainFrame">Accounts</a> | '."\n");
			//echo('			<a href="alert_accounts.php" target="mainFrame">Alerter Accounts</a> | '."\n");
		}
		echo('			<a href="scripts.php" target="mainFrame">GM scripts</a> | <a href="logout.php" >Logout</a>');

?>
		</td>
	</tr>
	<tr>
		<td>
			<iframe width="100%" height="100%" name="mainFrame" src="<?php echo($mainURL); ?>.php"></iframe>
		</td>
	</tr>
	</table>
</body>
</html>